The Image Compression Manager provides image-compression and image-decompression services to applications and to other managers. If you are developing an application that works with images (including sequences of images), you should read the material listed in this chapter.
If you want to develop a compresser or decompressor for use with QuickTime, you should read the following chapters as well: " "Component Manager," and "Codec Components."
Introduction to the Image Compression ManagerInside Macintosh introduces the features of the Image Compression Manager and discusses the topic of image compression generally. Included are discussions of:
New Features of the Image Compression ManagerQuickTime 4 Reference describes features added to the Image Compression Manager subsequent to QuickTime 1.6. Developers already familiar with QuickTime may want to begin here. The new features include:
Inside Macintosh provides a brief overview of the characteristics of image compression algorithms, including discussions of compression ratios, compression speed, and image quality.
Compressors Supplied by AppleInside Macintosh describes the compressors supplied by Apple, and included with QuickTime 1.6 (compressors added to QuickTime after version 1.6 are not discussed). Included is a detailed discussion of which types of images are most suitable for which compressors, with illustrative graphs of compression ratios. Note that this early documentation refers to the cinepak codec as the "Compact Video Compressor."
Inside Macintosh describes how to use the Gestalt Manager to determine what version of the Image Compression Manager is available. Included is a brief discussion of the information about compressors and compressed data that can be obtained from the Image Compression Manager.
Working with PicturesInside Macintosh discusses the functions provided by the Image Compression Manager for working with compressed images stored in version 2 PICT files. Macintosh developers who work with PICT files will find this information useful. Windows developers may also find this useful, or may wish to convert any PICT images to device independent bitmaps instead.
Compressing ImagesInside Macintosh describes the basic steps that your application follows when compressing a single frame of image data. Sample code is included for compressing and decompressing an image.
Decompressing ImagesInside Macintosh describes the steps your application must follow to decompress and image into a pixel map. A brief discussion of mask regions and blend mattes is included.
Compressing SequencesInside Macintosh provides a high level introduction to the topic of compressing sequences of images. This is followed by a detailed discussion of the steps your application must perform to compress a sequence of images using the Image Compression Manager.
Decompressing SequencesInside Macintosh describes how to use the low level functions of the Image Compression Manager to decompress a sequence of images (The high level functions that perform this task are described in the "Movie Toolbox" and "Movie Toolbox Reference" chapters). Included is a discussion of decompressing still images from a sequence, and a discussion concerning screen buffers and image buffers.
Important: The use of screen buffers has been discontinued in QuickTime 2.1 and later. Use only image buffers. A request for a screen buffer will return an image buffer. Do not request a screen buffer in your application.
A Sample Program for Compressing and Decompressing a Sequence of ImagesInside Macintosh provides a sample program illustrating the processes used to compress and decompress image sequences. The listing is broken up into a main program and a series of functions. Each function is introduced with a discussion of its purpose.
Inside Macintosh describes how (and when) to spool image data to or from storage other than computer memory. This allows you to work with sequences that contain more image data than your application has memory to hold.
Banding and Extending ImagesInside Macintosh describes two methods the Image Compression Manager uses to deal with incompatibilities between source data and codecs. If the source data is too large for the codec to deal with, the image is broken into bands. A band is a horizontal strip that is at least as wide as the image, but not as tall. If the codec requires image data to be a multiple of its block size, and the image is not an integer multiple, the image data is extended to the right and/or to the bottom. The extensions exist only in the image buffer, and are not displayed.
Defining Key Frame RatesInside Macintosh describes key frames and key frame rates, and explains how your application can set or change the key frame rate when compressing a sequence. Key frames define starting points for portions of a temporally-compressed sequence. Subsequent frames depend on the previous key frame.
Inside Macintosh briefly describes the fast dithering technique available with Apple-provided decompressors. This technique can be used when displaying high pixel-depth images on 8-bit displays.
Understanding Compressor ComponentsInside Macintosh gives an overview of image compressor components. This will be of interest primarily to developers wishing to develop their own codecs or other components. Included is a brief description of application-defined callback functions.
Getting Information About Compressor ComponentsInside Macintosh describes functions that allow your application to gather information about the Image Compression Manager and the installed compressor components.
Getting Information About Compressed DataInside Macintosh describes the functions that your application can use to obtain information about compressed images, or about images that are to be compressed. You may need this information to allocate a buffer of the correct size, for example. A function is provided to compare two images, which may be helpful in determining key frame placement.
Working With ImagesInside Macintosh describes the functions your application can use to compress and decompress single-frame images stored as pixel maps. (Sequences of images are discussed in "Working With Sequences," below. Single-frame images stored in PICT files are discussed in "Working With Pictures and PICT Files," also below.) The functions provided include high-level and low-level compression and decompression, conversion between different compression formats, trimming to fit a rectangle, and getting and setting custom color tables.
Inside Macintosh describes the functions your application can use to compress and decompress images stored as pictures and PICT files. (Single-frame images stored as pixel structures are discussed in the section "Working With Images," above.) Both high level and low level functions are provided for compression. The draw functions combine decompression and display.
Inside Macintosh describes functions that your application can use to create "thumbnails", small representative pictures, from existing images stored as pixel maps, pictures, or picture files. Thumbnail pictures are typically used for previews, which are described in the chapters "Movie Toolbox" and "Movie Toolbox Reference."
Working With SequencesInside Macintosh describes the basic functions used to compress and decompress a sequence of images. Note that the sequence itself contains no time information, only the order in which images should appear. QuickTime 4 Reference defines several new functions for working with sequences, including functions supporting timecodes and asynchronous decompression. Note that two of the new functions, DecompressSequenceBeginS and DecompressSequenceFrameS, are enhancements of original functions with the same names, minus the terminal "S".
Inside Macintosh describes the functions your application can use to manipulate the parameters that control sequence compression, and to get information about memory that the compressor has allocated. A number of parameters can be set with these functions, including key frame rate, frame sequence, and image quality. QuickTime 4 Reference defines an additional function which adds support for packetization.
Inside Macintosh defines two functions and a data structure that allow your application to communicate with compressors that can constrain compressed data to a specific data rate. Such codecs are used to ensure that a movie will play smoothly over a minimum-speed CD-ROM, internet, or intranet connection.
Working With Data SourcesQuickTime 4 Reference describes the functions your application can use to provide a codec with multiple input sources. This allows the codec to provide blends, transitions, and other effects that require multiple sources of data.
QuickTime 4 Reference defines the functions which allow your application to work directly with interlaced video fields. This allows you to pass field data to codecs that may, for example, combine two fields, without having to decompress and recompress the fields first.
Controlling Hardware ScalingQuickTime 4 Reference describes functions that allow your application to make use of hardware zoom, if it is available on the computer being used. Two hundred percent hardware scaling can be used, for example, to present a quarter-screen movie on a full screen, even if the computer is not fast enough to perform software scaling in real time. Functions are defined for determining whether scaling is available, and for reading and setting the current scaling factor. The functions are:
Image Transcoding FunctionsQuickTime 4 Reference describes the functions your application can use to invoke a transcoder. A transcoder translates an image compressed in one format into a different compression format. A transcoder can use an algorithm that directly translates from one format into another, which is often faster and more accurate than decompression and recompression. If your application requests decompression of an image, but no decompressor for the image can be found, QuickTime will search for a transcoder that can be used to convert the image into a format for which a decompressor is available. The transcoder functions directly available to your application are:
Inside Macintosh discusses the functions your application can use to manipulate the parameters that control sequence decompression, and to get information about memory that the decompressor has allocated.
Inside Macintosh describes functions that give your application access to compressed data as it is being displayed, or to intercept compressed data before it is decompressed and displayed. This extends the grafProcs field of the color graphics port structure (CGraphPort) to support compressed data, mattes, and matrices. The functions are:
Aligning WindowsInside Macintosh describes the functions your application can use to position and drag windows to optimal screen offsets, for best performance on various bit-depth displays. For example, rectangles can be aligned horizontally to multiples of 4 pixels on 8-bit displays, and multiples of 2 pixels on 16-bit displays. This can substantially improve decompressor performance. See also: "Application-Defined Functions," later in this chapter. The functions provided are:
Working with Graphics Devices and Graphics WorldsInside Macintosh describes two functions that enable your application to select graphics devices and create graphics worlds. Your application can use these functions to select the highest bit-depth display available, or to create a graphics world based on the width, height, depth, and color table of an image-description structure.
Working With Graphics ImportersQuickTime 4 Reference defines the functions an application can use to locate and open a graphics importer component for a file or data reference.
Working With Image Description RecordsQuickTime 4 Reference defines the functions an application can use to manipulate image description records.
Inside Macintosh describes the structure of callback functions that your application can define to work with compressor components and the window alignment function. Sample functions are given for data-loading and data-unloading, which are used to spool data that will not fit in a codec's memory space. A sample completion function allows a codec to alert your application that an asynchronous task is complete. A sample progress function allows your application to display a progress indicator during a long codec function. The alignment function allows you to modify the default pixel alignment of a rectangle on the screen.
Inside Macintosh describes the format and content of the data structures, data types, and constants that you will use to exchange information with the Image Compression Manager. QuickTime 4 Reference defines several new control flags and constants. The data types that are defined include: